package cn.wolfcode.producer.controller._01_springboot_producer;

import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ProducerController {
    @Autowired
    private RocketMQTemplate template;

    //同比的方式
    @GetMapping("/send")
    public String sendMsg(String msg){
//        MessageBuilder<String> builder = MessageBuilder.withPayload(msg);
//        org.springframework.messaging.Message<String> message = builder.build();
//        template.send("01-boot-hello",message);
        template.syncSend("01-boot-hello", msg);
        return "发送成功";
    }


    //异步的方式
    @GetMapping("/asyncsend")
    public String asyncsendMsg(String msg){
        template.syncSend("01-boot-hello", msg);



        return "发送成功";
    }

}
